<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<title>${title}</title>
<%@include file="/WEB-INF/templates/common/common.jsp"%>
<script type="text/javascript" src="${basePath}/static/page/js/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
<script  type="text/javascript" src="${basePath}/static/js/util.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">
</head>
<body>

</head>
<body>
 <!--头部-->
 <%@include file="/WEB-INF/templates/common/header.jsp"%>

<!------导航条-->
 <%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<div class="list_main lay_out">
 <div class="list_DH">
    <!--打印模块导航栏-->
 <%@include file="/WEB-INF/templates/common/printnav.jsp"%>
 </div>
 <div class="list_NR">
  <div class="loc">
   <h3>打印详情</h3>
  </div>
 
  <div class="list_con_table"> 
   <div class="search_table">
    <ul id="table_ul">
    <li class="Label_1" style="width:15%">病案所属人姓名：&nbsp;</li>
    <li class="Label_2" style="width:16%"><input class="input_box" type="text" maxlength="40" name='name' id='name'  /></li>
     <li class="Label_1" style="width:12%">ID号：&nbsp;</li>
    <li class="Label_2" style="width:16%"><input class="input_box" type="text" maxlength="40" name='mrId' id='mrId'  /></li>
     <li class="Label_1">打印时间：</li>
     <li class="Label_2" style="width:27%;text-align:left">
     <input style="width:44%;margin-left:5px" class="input_box" id="timeStart" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text"  name=''  value='' /> 
     - <input style="width:44%" class="input_box" id="timeEnd" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text"  name=''  value='' />
     </li>
    
    <li class="Label_5">
	   <a onclick="findMr(1,10)">查询</a>
	  <!--  <a onclick="exportPrintDetailToExcel()">导出</a> -->
    </li>
    </ul>
  </div>
  <table class="Search_tableList" cellpadding="0" cellspacing="0">
		      <tr>
		      <td class="tdLabel_4">姓名</td>
		      <td class="tdLabel_4">ID号</td>
		      <td class="tdLabel_4">身份证号</td>
		       
		       <td class="tdLabel_4">出院时间</td>
		      <td class="tdLabel_4">出院科室</td>
		      <td class="tdLabel_4">打印页数</td>
		      <td class="tdLabel_4">打印时间</td>
		      <td class="tdLabel_4">申请人</td>
		     <!--  <td class="tdLabel_4">操作人</td> -->
		       <td class="tdLabel_4">操作</td>
		      </tr>
		      <tr id="loading" style="height:50px;display:none">
	             <td colspan="9" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	          </tr>
		      <tbody id="tbody">
				<%-- <c:if test="${!empty printRecordList}">
					<c:forEach items="${printRecordList}" var="printRecord">
						<tr>
							<td class="tdLabel_5">${printRecord.name}</td>
							<td class="tdLabel_5">${printRecord.id_card}</td>
							<td class="tdLabel_5">${printRecord.mr_id}</td>
							<c:if test="${printRecord.print_reason==1}">
							<td class="tdLabel_5">门规</td>
							</c:if>
							<c:if test="${printRecord.print_reason==2}">
							<td class="tdLabel_5">医保</td>
							</c:if>
							<c:if test="${printRecord.print_reason==3}">
							<td class="tdLabel_5">其他</td>
							</c:if>
							<td class="tdLabel_5">${printRecord.print_page}</td>
							<td class="tdLabel_5">${printRecord.print_time}</td>
							<td class="tdLabel_5">${printRecord.out_time}</td>
							<td class="tdLabel_5">${printRecord.operator}</td>
						</tr>
					</c:forEach>
				</c:if> --%>
		      </tbody>
     </table>
    <div class="pageList">
       <ul class="pagination clearfix" id="page_plus"></ul>
       <div class="pagination">
            <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
       </div>          
    </div>
 </div>
</div>
</div>
<!--页脚部分-->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>
<!--  " <td  class='tdLabel_5'><a mrId='"+mrBasic.mr_id+"' treatment='"+mrBasic.treatment_type_name+"'  firstGuid='"+mrBasic.first_level_medical_guid+"'  mrName='"+mrBasic.name+"' idCard='"+mrBasic.id_number+"' orgName='"+mrBasic.hospital_name+"'  outTime='"+mrBasic.out_hospital_date+"' onclick='dirprint(this)'>打印</a></td>"+ -->
 <script>
/*  	function exportPrintDetailToExcel(){
 		var name=$("#name").val();		
 		var startTime=$("#timeStart").val();
 		var endTime=$("#timeEnd").val();
 		if((name==null || name=='')&&(startTime==null || startTime=="")&&(endTime==null || endTime=="")){
 			layer.alert('导出条件不能为空', {icon: 0}); 
 			return;
 		}
 		$.ajax({
 			type:"get",
 			url:"${basePath}/print/selectPrintRecordByCondition",
 			data:{name:name,startTime:startTime,endTime:endTime},
 			success:function(data){
	 			if(data.data.listSize>0){
	 				location.href="${basePath}/print/exportPrintRecordToExcel?name="+name+"&startTime="+startTime+"&endTime="+endTime+"";
	 			}else{
	 				layer.alert('导出数据为空', {icon: 5}); 
	 			}
 			}
 		})
 	} */
 
 	function findMr(pageNo,pageSize){
 		var name=$("#name").val();	
 		var mrId=$("#mrId").val();	
 		var startTime=$("#timeStart").val();
 		var endTime=$("#timeEnd").val();
 		if((mrId==null || mrId=='')&& (name==null || name=='')&&(startTime==null || startTime=="")&&(endTime==null || endTime=="")){
 			layer.alert('查询条件不能为空', {icon: 0}); 
 			return;
 		}
 		//{"hospitalizationNotes":[{"mr_id":"0158981","id_number":"130625284798787009","treatment_type_name":"住院","out_hospital_date":"2017-09-24","name":"赵尊号","id":5,"first_level_medical_guid":"ad820cdb37fc493aa820caa4c36c8cfd","hospital_name":"山东省立医院"}],"medRecordQuery":{"currentStartNum":0,"totalPages":1,"name":"赵尊号","pageSize":1,"currentPage":1,"totalCounts":1}}
 		//jQuery.support.cors = true;
 		$.ajax({
 			type:"post",
 			url:"${basePath}/print/selectPrintRecordByCondition",
 			data:{name:name,mrId:mrId,startTime:startTime,endTime:endTime,pageNo:pageNo,pageSize:pageSize},
 			beforeSend:function(){
 				$("#tbody").html("");
 				$("#loading").show();
 			},

 			success:function(data){
 				console.log(data);
 				$("#loading").hide();
 			if(data!=null && data!=""){
 		
 				initPage(data.data.totalCount,pageSize,pageNo);
 				var hospitalizationNotes=data.data.printList;
 				var html="";
 			 	for(var i=0;i<hospitalizationNotes.length;i++){
 					var mrBasic=hospitalizationNotes[i];
 					html+="<tr>"+
 					      " <td  class='tdLabel_5'>"+mrBasic.name+"</td>"+
 					   	  " <td  class='tdLabel_5'>"+mrBasic.mrId+"</td>"+
 					      " <td  class='tdLabel_5'>"+(mrBasic.idNumber==undefined?'':mrBasic.idNumber)+"</td>"+
 					   	  " <td  class='tdLabel_5'>"+mrBasic.outHospitalDate+"</td>"+
 					      " <td  class='tdLabel_5'>"+mrBasic.outOfficeName+"</td>"+
 					      " <td  class='tdLabel_5'>"+(mrBasic.printNum?mrBasic.printNum:'')+"</td>"+
 					      " <td  class='tdLabel_5'>"+mrBasic.printTime+"</td>"+
 					     " <td  class='tdLabel_5'>"+mrBasic.applyMan+"</td>"+
 					 /*    " <td  class='tdLabel_5'>"+mrBasic.printMan+"</td>"+ */
 					   " <td  class='tdLabel_5'><a class='int' target='_blank' href='${basePath}/print/printRecordDetail?medicalPrintId="+mrBasic.medicalPrintId+"'>查看</a></td>"+
 					      "</tr>";
 				}
 				$("#tbody").html(html);
 			}else{
 				layer.alert('查询数据为空', {icon: 5}); 
 				$("#tbody").html("");
 				
 			}
 			
 			
 			}
 		})
 	}
 	
	function page(currentPage,totalCounts){
	
	var totalCounts = totalCounts;
 		var pageSize = 10;
 		var totalPages = Math.ceil(totalCounts/pageSize);
 		$("#ston_page_msg").text(totalPages);
 		
 		$("#Pagination").pagination(totalPages,{
 		current_page:currentPage,
 	  callback: function (page_index,jp) {
 		findMr(page_index,pageSize);
 	  } 
 	  
 	  });
	}
	
  //分页
	function initPage(totalCounts,pageSize,currentPage){
		 var visiblePages = 5;
		 var totalPages =Math.ceil(totalCounts/pageSize);
		 $("#totalPage").html(totalCounts);
		 if(totalCounts < 1){
		 	$("#currentPage").html(0+"/"+totalPages);
		 	$("#page_plus").html("");
		 	return;
		 }
		 
         $("#currentPage").html(currentPage+"/"+totalPages);
         
		 $('#page_plus').jqPaginator({

		        totalCounts: totalCounts,
		        pageSize:pageSize,
		        visiblePages: visiblePages,
		        currentPage: currentPage,

		        first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
		        prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
		        next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
		        last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
		        page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
		        onPageChange: function (page,type) {
		        	if(type !='init'){
		        		findMr(page,pageSize);
			        }
		        }
		    });

	}	
  
  
  function dirprint(obj){
	  var isMail=$('input:radio[name="mail"]:checked').val();
	  var printReason=$("#applyReason").val();
	  var name=$(obj).attr("mrName");
	  var mrId=$(obj).attr("mrId");
	  var firstGuid=$(obj).attr("firstGuid");
	  var idCard=$(obj).attr("idCard");
	  var outTime=$(obj).attr("outTime");
	 
	  if(isMail==1){
		  window.location.href="${basePath}/print/addPrintRecordPage?name="+name+"&idCard="+idCard+"&mrId="+mrId+"&printReason="+printReason+"&firstGuid="+firstGuid+"&isMail="+isMail+"&outTime="+outTime+"";
	  }else{
		  window.location.href="${basePath}/print/addPrintMailRecordPage?name="+name+"&idCard="+idCard+"&mrId="+mrId+"&printReason="+printReason+"&firstGuid="+firstGuid+"&isMail="+isMail+"&outTime="+outTime+"";
	  }
	 
  }
  
  
  function verificationPrintreason(printreason){
	  if(printreason=="1"){
		  return "门规";
	  }
	  if(printreason=="2"){
		  return "医保";
	  }
	  if(printreason=="3"){
		  return "其他";
	  }
  }
  
  
	 
	
	</script>

</body>
</html>
